//
//  ExpressionController.m
//  OCDemo
//
//  Created by BH on 15/10/12.
//  Copyright © 2015年 baohan. All rights reserved.
//

#import "ExpressionController.h"

@interface ExpressionController ()

@end

@implementation ExpressionController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(Class)labelClass
{
    return [MLLinkLabel class];
}

-(NSInteger)resultCount
{
    return 2;
}

-(void)changeToResult:(NSInteger)result
{
    self.label.textColor = [UIColor redColor];
    self.label.font = [UIFont systemFontOfSize:14.f];
    self.label.textAlignment = NSTextAlignmentCenter;
    self.label.textInsets = UIEdgeInsetsMake(5, 5, 5, 5);
    self.label.numberOfLines = 0;
    
    LABEL.allowLineBreakInsideLinks = NO;
    LABEL.linkTextAttributes = nil;
    LABEL.activeLinkTextAttributes = nil;
    
    MLExpression *exp = [MLExpression expressionWithRegex:@"\\[[a-zA-Z0-9\\u4e00-\\u9fa5]+\\]" plistName:@"Expression" bundleName:@"ClippedExpression"];
    
    LABEL.attributedText = [@"人生若只如初见，[坏笑]何事秋风悲画扇。http://baidu.com等闲变却故人心[亲亲]，dudl@qq.com却道故人心易变。13612341234骊山语罢清宵半[心碎了]，泪雨零铃终不怨[左哼哼]。#何如 薄幸@锦衣郎，比翼连枝当日愿。" expressionAttributedStringWithExpression:exp];
    
    [LABEL setDidClickLinkBlock:^(MLLink *link, NSString *linkText, MLLinkLabel *label) {
        
        SHOW_SIMPLE_TIPS(TIPS);
    }];
    
    if (result == 0) {
        
    }else{
        LABEL.numberOfLines = 1;
        LABEL.attributedText = [@"扬之水，[得意]不流束楚" expressionAttributedStringWithExpression:exp];
    }
    
    self.label.frameWidth = self.view.frameWidth - 10.f*2;
    [self.label sizeToFit];
}

@end
